#ifndef HUMITEMPCTRLIB_H_
#define HUMITEMPCTRLIB_H_

#include <stdint.h>
#include "tempctrlib.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define HUMI_AUTO_BACK_MAX 1

	typedef enum
	{
		HUMI_INC_INIT = 0,
		HUMI_INC_FULL,
		HUMI_CLR,
		HUMI_INC,
		HUMI_AUTO,
		HUMI_BACKUP
	} HUMI_CTR_STEP_Type;

	typedef enum
	{
		HUMI_DIR_DOWN = 0,
		HUMI_DIR_UP = 1,
	} HumiDirType;

	typedef enum
	{
		HUMI_TEMP_CTR_MODE_NOCOOL_NOCLR = 0,
		HUMI_TEMP_CTR_MODE_COOL = 1,
		HUMI_TEMP_CTR_MODE_HUMICLR = 2,
	} CtrModeType;

	typedef struct
	{
		TadjModeType AdjMode;		 
		uint8_t b_temp_man_on;		 
		uint8_t b_temp_man_cool_req; 
		uint16_t temp_man_heat_out;	 
		uint8_t bHumiManOn;			 
		uint8_t bManHumiCoolReq;	 
		uint16_t ManHumiOut;		 

		uint8_t bCoolForce;				  
		CtrModeType CtrMode;			  
		CtrModeType CtrModeOld;			  
		temp_ctr_step_type temp_ctr_step; 
		temp_ctr_step_type temp_ctr_step_old;
		int8_t b_temp_dir;			   
		int8_t b_temp_dir_old;		   
		int8_t b_temp_dir_at_dly_end;  
		uint8_t temp_keep_cnt;		   
		uint8_t temp_dir_keep_cnt;	   
		uint8_t wave_cnt;			   
		uint8_t SubAdjCnt;			   
		uint8_t bTempCoolDis;		   
		uint8_t b_cool_req;			   
		uint8_t b_cool_req_old;		   
		uint8_t b_temp_cool_req;	   
		uint8_t bTempAdjDone;		   
		uint8_t b_edge_cool_delay_end; 
		int16_t temp_pv;			   
		int16_t temp_sv;			   
		int16_t TempAtCoolStart;	   
		int16_t temp_for_dir;		   
		int16_t temp_cool_dly_end;	   
		int16_t temp_cool_end;		   
		int16_t st_temp_cool_end;	   
		int16_t temp_cool_en;		   
		int16_t temp_cool_dis;		   
		int16_t temp_heat_close;	   
		int16_t temp_ctr_limite;	   
		int16_t temp_max;			   
		int16_t temp_min;			   
		int16_t TempMaxOld;			   
		int16_t TempMinOld;			   
		int16_t temp_old;			   
		int16_t temp_sv_old;		   
		int16_t cool_dly_time_sv;	   
		int16_t cool_dly_time_sv_old;  
		int16_t cool_dly_time_cnt;	   
		int16_t cool_close_time_cnt;   
		int16_t TempCtrSvAtCoolOffset; 
		int32_t heat_out;			   
		pid_type pid_temp;			   

		int16_t cool_time_cnt;	   
		int16_t cool_time_cnt_old; 
		int16_t CoolCloseTimeCnt;  
		int16_t cool_time_set;	   
		
		uint8_t StHumiCtrEn;			
		uint8_t StHumiAdjEn;			
		uint8_t bCoolClrCloseByTemp;	
		HUMI_CTR_STEP_Type HumiCtrStep; 
		HUMI_CTR_STEP_Type HumiCtrStepOld;
		HumiDirType bHumiDir;		   
		HumiDirType bHumiDirLast;	   
		HumiDirType bDeayEndHumiDir;   
		uint8_t bHumiClrDis;		   
		uint8_t bHumiCoolReq;		   
		uint8_t bHumiAdjDone;		   
		uint8_t HumiKeepCnt;		   
		uint8_t HumiDirKeepCnt;		   
		int16_t HumiForDir;			   
		int16_t HumiCur;			   
		int16_t HumiSet;			   
		int16_t HumiSetLast;		   
		int16_t HumiCtrTemp;		   
		int16_t HumiIncClose;		   
		int16_t HumiClrEn;			   
		int16_t HumiClrDis;			   
		int16_t HumiCtrLimiteL;		   
		int16_t HumiCtrLimiteH;		   
		int16_t HumiCtrLimiteCenter;   
		int16_t HumiCtrLimiteAverage;  
		int16_t HumiDelayEnd;		   
		int16_t HumiClrEnd;			   
		int16_t StHumiClrDelayEnd;	   
		int16_t HumiMax;			   
		int16_t HumiMin;			   
		int16_t HumiMaxOld;			   
		int16_t HumiMinOld;			   
		int16_t NoHumiCoolTimeCnt;	   
		int16_t HumiCtrSvAtCoolOffset; 
		int32_t HumiOut;			   
		pid_type HumiPid;			   

		uint32_t TimeCnt;
		uint32_t StepTimeCnt;
	} HUMITEMP_CTR_PAR_Type;

	void HT_Control(HUMITEMP_CTR_PAR_Type *CtrPar);

#ifdef __cplusplus
}
#endif

#endif 
